package com.qingke.POJO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport{
	
	public String exectue(String name,String user,String password){
		String sql = "select * form sui where name=? and usesr=? and password=?";
		Connection conn = null ;
		PreparedStatement ps = null;
		ResultSet rs = null;
		try{
			conn = getConnection();
			ps = conn.prepareStatement(sql);
			ps.setString(1, name);
			ps.setString(2, user);
			ps.setString(3, password);
			rs = ps.executeQuery();
			if("".equals(rs.next())){
				
			}
		}catch (SQLException e) {
            e.printStackTrace();
        }
		return name;
		
	}
	 public Connection getConnection() throws SQLException{

	      String driver = "com.mysql.jdbc.Driver";
	      String url="jdbc:mysql://localhost:3306/sui?useSSL=false";
	      String username = "root";
	      String password = "xyaychA153813";

	      try {
	          Class.forName(driver);
	      } catch (ClassNotFoundException e) {
	          throw new RuntimeException(e);
	      }

	      Connection conn = DriverManager.getConnection(url, username, password);
	      return conn;
	  }

		public void cleanup(Connection conn, Statement statement, ResultSet rs) {
	      if (rs != null) {
	          try {
	              rs.close();
	          } catch (SQLException e) {
	              throw new RuntimeException(e);
	          }
	      }
	      if (statement != null) {
	          try {
	              statement.close();
	          } catch (SQLException e) {
	              throw new RuntimeException(e);
	          }
	      }
	      if (conn != null) {
	          try {
	              conn.close();
	          } catch (SQLException e) {
	              throw new RuntimeException(e);
	          }
	      }
	  }
}
